<template>
	<view class="content">
		<view class="dis_sb ml20 mr20 line26 mb20 pl20 bgfff">
			<view class="dis_sc">
				<view>日期选择：</view>
				<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
					<view class="">{{date}}</view>
				</picker>				
			</view>
			<button class="bgblue  line18 clo-fff f28 pl20 pr20 mr20">查询</button>
		</view>
		
		<view class="main">
			<view v-for="(item,index) in list" @click="detail()" class=" dis_sb bgfff pt10 pb10 ml20 mr20 mb20 pl20 pr20 line18">
				<view class="w100">
					<view>{{item.id}}</view>
					<view>{{item.name}}</view>
					<view class="clo-999 f24">订单时间：{{item.date}}</view>
				</view>
				<view class="clo-blue tac w35 shrink"><view>收款金额(元)</view>	<text class="f34 fwb">{{item.money}}</text></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			const currentDate = this.getDate({
			    format: true
			})
			return {
				date: currentDate,
				list:[
					{
						id:'1236547896541236',
						name:'这里显示用户授权ID',
						date:"2024-01-03 10:23:12",
						money:"45.23"
					},
					{
						id:'1236547896541236',
						name:'这里显示用户授权ID',
						date:"2024-01-03 10:23:12",
						money:"45.23"
					},
					{
						id:'1236547896541236',
						name:'这里显示用户授权ID',
						date:"2024-01-03 10:23:12",
						money:"45.23"
					},
					{
						id:'1236547896541236',
						name:'这里显示用户授权ID',
						date:"2024-01-03 10:23:12",
						money:"45.23"
					},
					{
						id:'1236547896541236',
						name:'这里显示用户授权ID',
						date:"2024-01-03 10:23:12",
						money:"45.23"
					},
					{
						id:'1236547896541236',
						name:'这里显示用户授权ID',
						date:"2024-01-03 10:23:12",
						money:"45.23"
					},
					{
						id:'1236547896541236',
						name:'这里显示用户授权ID',
						date:"2024-01-03 10:23:12",
						money:"45.23"
					}
				]
			}
		},
		computed: {
		        startDate() {
		            return this.getDate('start');
		        },
		        endDate() {
		            return this.getDate('end');
		        }
		},
		onLoad() {

		},
		methods: {
			detail(){
				uni.navigateTo({
					url:'/pages/index/orderDetail'
				})
			},
			bindDateChange: function(e) {
			    this.date = e.detail.value
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			}
		}
	}
</script>

<style>
	
	.content {background: linear-gradient(#3172f9 10%, #f8f8f8); padding-top: 20rpx; min-height: 100%;}
	
	.main {height: 87vh; overflow-y: auto;}
</style>
